package org.rabbit.message;

import java.io.IOException;

import org.rabbit.pojo.User;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.rabbitmq.client.Channel;


@RabbitListener(queues= {"fanoutqueue1"})
@Component
@Transactional
public class UserMessageReciever3 {
	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
	@RabbitHandler
	public void process(User u) {
		System.out.println("abc发红包了！！！！！！！！！！！"+u);
	}
	
	/**
	 * @param text消息内容
	 * @param channel 消息通信对象
	 * @param message封装的消息对象
	 * @throws IOException 
	 * 
	 */
	
	
	@RabbitHandler
	public void process(String text,Channel channel,Message message) throws IOException {
		System.out.println("abc发红包了！！！！！！！！！！！"+text);
		//消息的确认第一个参数为消息的全局标识，第二个为是否一次确认多条消息
		channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
	}
	
	
}
